{extend name="public:layout" /}
{block name="title"}发票管理{/block}
{block name="head"}
<style>
    i{cursor:pointer}
</style>
{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> 发票列表</li>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <div class="pull-right">
                    <form class="form-inline" method="post" id="searchForm">
                        <input type="hidden" name="invoice" id="invoice" value="{$query.invoice}" />
                        <div class="form-group">
                            <input class="form-control" name="order_sn" value="{$query.order_sn}" type="text" placeholder="检索订单编号">
                        </div>
                        <button type="submit" class="btn btn-info">
                            <i class="fa fa-search"></i> 搜索
                        </button>
                        <a class="btn btn-white" href="{:url('index')}">
                            <i class="fa fa-trash"></i> 清空
                        </a>
                    </form>
                </div>
                <div class="clearfix"></div>
            </div>
            <ul class="nav nav-tabs" id="tab_search">
                <li data-val="0" onclick="setInvoice(this)" {eq name="query.invoice" value="0"}class="active"{/eq}><a href="javascript:;">所有发票</a></li>
                <li data-val="1" onclick="setInvoice(this)" {eq name="query.invoice" value="1"}class="active"{/eq}><a href="javascript:;">未开发票</a></li>
                <li data-val="2" onclick="setInvoice(this)" {eq name="query.invoice" value="2"}class="active"{/eq}><a href="javascript:;">已开发票</a></li>
                <li data-val="3" onclick="setInvoice(this)" {eq name="query.invoice" value="3"}class="active"{/eq}><a href="javascript:;">已寄出发票</a></li>
            </ul>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="150">订单编号</th>
                    <th>发票类型</th>
                    <th>发票抬头</th>
                    <th>纳税人识别号</th>
                    <th>寄送地址</th>
                    <th width="120">操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="orderList" id="vo"}
                <tr>
                    <td>
                        <a href="javascript:;" onclick="showDetail(this)" data-url="{:url('ShopOrder/orderDetail',['order_sn'=>$vo['order_sn']])}">{$vo.order_sn}</a>
                    </td>
                    <td>
                        {eq name= "vo.invoice_info.inv_state" value="1"}普通发票{else/}增值税发票{/eq}
                    </td>
                    <td>
                        {eq name= "vo.invoice_info.inv_state" value="1"}
                        {$vo.invoice_info.inv_title}
                        {else/}
                        {$vo.invoice_info.inv_title}
                        {/eq}
                    </td>
                    <td>{$vo.invoice_info.inv_code}</td>
                    <td>
                        {$vo.invoice_info.inv_info.addr_consignee} {$vo.invoice_info.inv_info.addr_tel}
                        {$vo.invoice_info_area_name}
                        {$vo.invoice_info.inv_info.addr_address}
                    </td>
                    <td>
                        <a href="{:url('edit',['order_id'=>$vo['order_id']])}">处理发票</a>
                        <a href="javascript:;" onclick="doAction(this);"
                           data-msg="确认删除吗？" data-url="{:url('del')}"
                           data-params="order_id={$vo.order_id}">删除</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            <div class="page-bar">{$orderList->render()}</div>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    //显示订单详情
    function showDetail(obj) {
        var url = $(obj).data('url');
        openDialog('订单详情', url, '800px', '520px');
    }
    //选取商品类型
    function setInvoice(obj) {
        var invoice = $(obj).data('val');
        $('#invoice').val(invoice);
        $('#searchForm').submit();
    }
</script>
{/block}